import pytz
from apscheduler.schedulers.blocking import BlockingScheduler
from do_main import main
# from del_file import delete


def task_start():
    scheduler_tz = pytz.timezone("Asia/Shanghai")
    scheduler = BlockingScheduler(timezone=scheduler_tz)

    scheduler.add_job(
        func=main,  # 数据下载与抽取主函数
        trigger="cron",
        hour=10,
        minute=0,
        second=0,
        timezone=scheduler_tz,
        misfire_grace_time=600,
        # run_promptly=True
    )
    # scheduler.add_job(
    #     func=delete,  # 删除5天前的数据
    #     trigger="cron",
    #     hour=10,
    #     minute=0,
    #     second=30,
    #     timezone=scheduler_tz,
    #     misfire_grace_time=600
    # )
    # scheduler.add_job(
    #     func=do_produce,  # grib文件转化为nc文件
    #     trigger="cron",
    #     hour=10,
    #     minute=1,
    #     second=0,
    #     timezone=scheduler_tz,
    #     misfire_grace_time=600
    # )

    scheduler.start()


if __name__ == '__main__':
    task_start()
